package com.li.sssp.server;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.li.sssp.entity.Actor;
import com.li.sssp.repository.ActorRepository;

@Service
public class ActorService {

	@Autowired
	private ActorRepository actorRepository;

	public List<Actor> getAll() {
		return actorRepository.findAll();
	}

	@Transactional
	public Page<Actor> getAll(Pageable page) {
		
		return actorRepository.findAll(page);
	}

	@Transactional
	public Actor getbyid(Integer id) {
		return actorRepository.findOne(id);
	}

	@Transactional
	public Actor save(Actor actor) {
		return actorRepository.saveAndFlush(actor);
	}

}
